home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / files.swg / 0083_Record Scrolling.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-11-22  |  2.8 KB  |  101 lines

  1. {
  2.  ms> Does anybody have a database scroling rutine. When I say a database
  3.  ms> scroling rutine I mean that you have som records which is longer than the
  4.  ms> screen and then you need to scroll up or down to view the rest of it.
  5.  
  6.  ms> In the rutine you should could scroll up and down.
  7.  
  8.   Here is a copy of a sort of generic viewing routine incorporating most of
  9. the VT100 keyboard commands, including home/end and pgup/pgdn.
  10. }
  11.  
  12. Procedure PrintScr;
  13.  
  14. Type
  15.    GenFile : String[80];
  16.  
  17. Var
  18.    QuitBrowse : Boolean;
  19.    BalString  : String[80];
  20.    M, Lin, Top : Integer;
  21.    Com, Key : Char;
  22.    DtaLen   : Word;
  23.    ViewFile : File of GenFile;
  24.  
  25. Begin
  26.    ClrScr;
  27.    QuitBrowse := False;
  28.    Top := 0;
  29.  
  30.    Assign(ViewFile,'yourfile.txt');
  31.    Reset(ViewFile);
  32.    DtaLen := Filesize(ViewFile) -1;
  33.  
  34.    While Not QuitBrowse Do
  35.      Begin
  36.        For Lin := Top to (Top+24) Do
  37.          Begin
  38.            Seek(ViewFile,Lin);
  39.            Read(ViewFile,LineData);
  40.            RetrLine(DtaHandle,Lin);
  41.            BalString[0] := #80;
  42.            For M := 1 to 80 Do
  43.              BalString[M] := LineData[M];
  44.            QWrite((Lin-Top)+1,1,CfgData.IFo+CfgData.IBa,BalString);
  45.          End;
  46.        Com := ReadKey;
  47.        Case Com Of
  48.          #0:
  49.             Begin
  50.               Key := ReadKey;
  51.               Case Key Of
  52.                 #73 : { PgUp }
  53.                      Begin
  54.                        Top := Top -24;
  55.                        If Top < 0 Then Top := 0;
  56.                      End;
  57.                 #81 : { PgDn }
  58.                      Begin
  59.                        Top := Top +24;
  60.                        If Top > DtaLen Then
  61.                           Top := DtaLen;
  62.                      End;
  63.                 #72 : { Up Arrow }
  64.                      Begin
  65.                        Dec(Top);
  66.                        If Top < 0 Then Top := 0;
  67.                      End;
  68.                 #80 : { Dn Arrow }
  69.                      Begin
  70.                        Inc(Top);
  71.                        If Top > DtaLen Then
  72.                           Top := DtaLen;
  73.                      End;
  74.                 #119,#132 : { ^Home / ^PgUp }
  75.                       Top := 0;
  76.                 #117,#118 : { ^End / ^PgDn }
  77.                       Begin
  78.                         Top := DtaLen -5;
  79.                         If Top < 0 Then Top := 0;
  80.                       End;
  81.               End; { Case Key }
  82.             End; { Case #0 }
  83.  
  84.          #27: { ESC }
  85.              QuitBrowse := True;
  86.  
  87.        End; { Case Com }
  88.      End;
  89.  
  90. End; { Procedure PrintScr }
  91.  
  92.  
  93.   You will, of course, need to modify the parameters and such to fit your own
  94. needs. As a rule, I use this as a pattern for viewing routines, adjusting as
  95. required for the type of material being displayed.
  96.  
  97.   Good luck,
  98.  
  99. RB
  100.  
  101.